<!-- 公众号信息  -->
<template>
    <div class='bgff h100 pd  dfgfdgtrt'>
        <div class=" sdfgdgdfyt">
            <n-form ref="formRef" label-width="200" :inline="false" size="normal" label-placement="left">
                <n-grid :cols="24" :x-gap="20">
                 
                    <n-form-item-gi span="24" label="开发者ID(AppID)：" path="" class="mt20">
                        <n-input v-model:value="formValue.AppID" type="text" placeholder="开发者ID(AppID)：" size="medium"
                            clearable></n-input>
                        <!-- <div class="iconfont dx-help z9 fz18 sz question-mark-icon">
                            <n-image src="https://duxinggj-1251133427.cos.ap-guangzhou.myqcloud.com/adminimg/gzhappid.png"
                                class="imgsjnnee" />
                        </div> -->
                    </n-form-item-gi>

                    <n-form-item-gi span="24" label="开发者密码(AppSecret)：" path="" class="mt20">
                        <n-input v-model:value="formValue.AppSecret" type="text" placeholder="请输入AppSecret" size="medium"
                            clearable></n-input>
                        <!-- <div class="iconfont dx-help z9 fz18 sz question-mark-icon">
                            <n-image src="https://duxinggj-1251133427.cos.ap-guangzhou.myqcloud.com/adminimg/gzhappid.png"
                                class="imgsjnnee" />
                        </div> -->

                    </n-form-item-gi>
                    <n-form-item-gi span="24" label="&nbsp;" class="mt20">
                        <div>
                            <n-button type="primary" size="medium" @click="saveFun" class="mt40">保存</n-button>
                        </div>
                    </n-form-item-gi>

                </n-grid>
            </n-form>
        </div>

    </div>
</template>
<script lang='ts' setup>
import { ref } from "vue"
import { callBack, dxpost, qurl, dxget } from "../../../util/index"
const sxname = 'xcxuserinfo'
const apiurl = 'dxgjAdmin/dxglobalSetting'
const isbj = ref(false) // 是否为编辑的状态
let bjid = 0
const qrUrl = ref();
const formValue = ref({
    title: "",
    AppID: "",
    AppSecret: "",
})
const getQRcode = async () => {
    const { data }: any = await dxget("wechar/gzh/user/getcreateQr", { id: 1 });
    qrUrl.value = data.qrUrl;
};
const initData = async () => {
    const { data }: any = await dxget(apiurl, { sxname, roleId: localStorage.id })
    if (data.length <= 0) {
        return
    }
    isbj.value = true
    bjid = data[0].id
    const dataw = JSON.parse(data[0].text)

    if (dataw.title) {
        formValue.value.title = dataw.title
    }
    if (dataw.AppID) {
        formValue.value.AppID = dataw.AppID
    }
    if (dataw.AppSecret) {
        formValue.value.AppSecret = dataw.AppSecret
    }
    // getQRcode()
}
initData()
const saveFun = async () => {
    if (!isbj.value) {
        const { errno }: any = await dxpost(apiurl, { sxname, roleId: localStorage.id, text: JSON.stringify(formValue.value) })
        if (errno == 0) {
            window.$message.success('操作成功！')
            return
        }
    } else {
        const { errno }: any = await dxpost(apiurl, { id: bjid, text: JSON.stringify(formValue.value) }, 'put')
        if (errno == 0) {
            window.$message.success('保存成功！')
        }
    }

}
</script>
<style scoped>
.sdfgdgdfyt {
    width: 600px;
}

.logo-context {
    border: 1px dashed #999;
    width: 250px;
    height: 100px;
    text-align: center;
    color: #999;
    cursor: pointer;
    background: #e0e0e0;
}

.logo-context.ab {
    width: 94px;
    height: 94px;
}

.logo-context.ac {
    width: 600px;
    height: 300px;
}

.from-box-ks {
    max-width: 560px;
}

.question-mark-icon {
    position: absolute;
    right: -40px;
    top: 0;
    width: 20px;
    height: 20px;
}

.imgsjnnee {
    opacity: 0;
}

.imgsjnnee {
    position: absolute;
    left: 0;
    top: 0;
    z-index: 99;
}

.save-btn {
    width: 120px;
}
.jjnsertwe {
     width: 200px;
     height: 200px;
     border: 1px solid #e0e0e0;
     border-radius: 4px;
     overflow: hidden;
   }
</style>